'''
threading.active_count()
 返回当前存活的线程对象的数量；通过计算len(threading.enumerate())长度而来
    The returned count is equal to the length of the list returned by enumerate().
'''
import threading,time

def run():
    thread = threading.current_thread() 
    print('%s is running...\n' % thread.getName())  #返回线程名称
    time.sleep(10) #休眠10S方便统计存活线程数量

if __name__ == "__main__":
    
    for i in range(10):
        print('The current number of threads is: %s' % threading.active_count())    #返回当前存活线程数量
        thread_alive = threading.Thread(target=run,name='Thread-***%s***' % i)
        thread_alive.start()
        time.sleep(10)
    thread_alive.join()
    print('\n%s thread is done...'% threading.current_thread().getName())
